home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / lwres / context.h next >
Encoding:
C/C++ Source or Header  |  2008-09-17  |  3.4 KB  |  130 lines

  1. /*
  2.  * Copyright (C) 2004, 2005  Internet Systems Consortium, Inc. ("ISC")
  3.  * Copyright (C) 2000, 2001  Internet Software Consortium.
  4.  *
  5.  * Permission to use, copy, modify, and distribute this software for any
  6.  * purpose with or without fee is hereby granted, provided that the above
  7.  * copyright notice and this permission notice appear in all copies.
  8.  *
  9.  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
  10.  * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  11.  * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
  12.  * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  13.  * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  14.  * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15.  * PERFORMANCE OF THIS SOFTWARE.
  16.  */
  17.  
  18. /* $Id: context.h,v 1.15.18.2 2005/04/29 00:17:21 marka Exp $ */
  19.  
  20. #ifndef LWRES_CONTEXT_H
  21. #define LWRES_CONTEXT_H 1
  22.  
  23. /*! \file */
  24.  
  25. #include <stddef.h>
  26.  
  27. #include <lwres/lang.h>
  28. #include <lwres/int.h>
  29. #include <lwres/result.h>
  30.  
  31. /*!
  32.  * Used to set various options such as timeout, authentication, etc
  33.  */
  34. typedef struct lwres_context lwres_context_t;
  35.  
  36. LWRES_LANG_BEGINDECLS
  37.  
  38. typedef void *(*lwres_malloc_t)(void *arg, size_t length);
  39. typedef void (*lwres_free_t)(void *arg, void *mem, size_t length);
  40.  
  41. /*
  42.  * XXXMLG
  43.  *
  44.  * Make the server reload /etc/resolv.conf periodically.
  45.  *
  46.  * Make the server do sortlist/searchlist.
  47.  *
  48.  * Client side can disable the search/sortlist processing.
  49.  *
  50.  * Use an array of addresses/masks and searchlist for client-side, and
  51.  * if added to the client disable the processing on the server.
  52.  *
  53.  * Share /etc/resolv.conf data between contexts.
  54.  */
  55.  
  56. /*!
  57.  * _SERVERMODE
  58.  *    Don't allocate and connect a socket to the server, since the
  59.  *    caller _is_ a server.
  60.  */
  61. #define LWRES_CONTEXT_SERVERMODE    0x00000001U
  62.  
  63. lwres_result_t
  64. lwres_context_create(lwres_context_t **contextp, void *arg,
  65.              lwres_malloc_t malloc_function,
  66.              lwres_free_t free_function,
  67.              unsigned int flags);
  68. /**<
  69.  * Allocate a lwres context.  This is used in all lwres calls.
  70.  *
  71.  * Memory management can be replaced here by passing in two functions.
  72.  * If one is non-NULL, they must both be non-NULL.  "arg" is passed to
  73.  * these functions.
  74.  *
  75.  * Contexts are not thread safe.  Document at the top of the file.
  76.  * XXXMLG
  77.  *
  78.  * If they are NULL, the standard malloc() and free() will be used.
  79.  *
  80.  *\pre    contextp != NULL && contextp == NULL.
  81.  *
  82.  *\return    Returns 0 on success, non-zero on failure.
  83.  */
  84.  
  85. void
  86. lwres_context_destroy(lwres_context_t **contextp);
  87. /**<
  88.  * Frees all memory associated with a lwres context.
  89.  *
  90.  *\pre    contextp != NULL && contextp == NULL.
  91.  */
  92.  
  93. lwres_uint32_t
  94. lwres_context_nextserial(lwres_context_t *ctx);
  95. /**<
  96.  * XXXMLG Document
  97.  */
  98.  
  99. void
  100. lwres_context_initserial(lwres_context_t *ctx, lwres_uint32_t serial);
  101.  
  102. void
  103. lwres_context_freemem(lwres_context_t *ctx, void *mem, size_t len);
  104.  
  105. void *
  106. lwres_context_allocmem(lwres_context_t *ctx, size_t len);
  107.  
  108. int
  109. lwres_context_getsocket(lwres_context_t *ctx);
  110.  
  111. lwres_result_t
  112. lwres_context_send(lwres_context_t *ctx,
  113.            void *sendbase, int sendlen);
  114.  
  115. lwres_result_t
  116. lwres_context_recv(lwres_context_t *ctx,
  117.            void *recvbase, int recvlen,
  118.            int *recvd_len);
  119.  
  120. lwres_result_t
  121. lwres_context_sendrecv(lwres_context_t *ctx,
  122.                void *sendbase, int sendlen,
  123.                void *recvbase, int recvlen,
  124.                int *recvd_len);
  125.  
  126. LWRES_LANG_ENDDECLS
  127.  
  128. #endif /* LWRES_CONTEXT_H */
  129.  
  130.